package cn.gson.crmdemo.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crmdemo.model.dao.ContractVoDao;
import cn.gson.crmdemo.model.mapper.ContractMapper;
import cn.gson.crmdemo.model.pojo.Contract;
import cn.gson.crmdemo.model.vo.ContractCustomerVo;

@Service
@Transactional(rollbackFor=Exception.class)
public class ContractService {
	@Autowired
	ContractVoDao cd;
	@Autowired
	ContractMapper cm;
	
	/**
	 * 查询合同
	 * @return
	 */
	public JSONArray selectContract() {
		return cm.selectContract();
	}
	
	
	/**
	 * 新增/修改合同
	 * @param emp
	 */
	public void addContract(ContractCustomerVo c) {
		cd.save(c);
	}
	
	
	/**
	 * 查询全部公司名称
	 * @return
	 */ 
	public JSONArray selectCompany() {
		return cm.selectCompany();
	}
	
	/**
	 * 模糊查询公司名称
	 * @return
	 */
	public JSONArray mhselectCompany(String a) {
		return cm.mhselectCompany(a);
	}
	
	/**
	 * 删除合同表
	 * @param a
	 */
	public void deleteContract(int a) {
		cd.deleteById(a);
	}
	
	
	/**
	 * 修改合同内容查询id
	 * @param a
	 * @return
	 */
	public JSONArray updateSelect(int a) {
		return cm.updateSelect(a);
	}
	
	
	/**
	 * 查询合同状态
	 * @param a
	 * @return
	 */
	public JSONArray selectState(int a) {
		return cm.selectState(a);
	}
}
